{% extends "inventory/base.html" %}
{% load crispy_forms_tags %}

{% block title %}{{ form_title }}{% endblock %}

{% block content %}
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">
                    <h2 class="h4 mb-0">{{ form_title }}</h2>
                </div>
                <div class="card-body">
                    <div class="row mb-4">
                        <div class="col-md-6">
                            <h5>商品信息</h5>
                            <div class="table-responsive">
                                <table class="table table-sm">
                                    <tr>
                                        <th>商品名称：</th>
                                        <td>{{ check_item.product.name }}</td>
                                    </tr>
                                    <tr>
                                        <th>商品条码：</th>
                                        <td><code>{{ check_item.product.barcode }}</code></td>
                                    </tr>
                                    <tr>
                                        <th>商品分类：</th>
                                        <td>{{ check_item.product.category.name }}</td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <h5>盘点信息</h5>
                            <div class="table-responsive">
                                <table class="table table-sm">
                                    <tr>
                                        <th>盘点名称：</th>
                                        <td>{{ inventory_check.name }}</td>
                                    </tr>
                                    <tr>
                                        <th>系统数量：</th>
                                        <td><strong class="text-primary">{{ check_item.system_quantity }}</strong></td>
                                    </tr>
                                    <tr>
                                        <th>状态：</th>
                                        <td>
                                            {% if inventory_check.status == 'in_progress' %}
                                            <span class="badge bg-primary">{{ inventory_check.get_status_display }}</span>
                                            {% endif %}
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                    </div>
                    
                    <form method="post">
                        {% csrf_token %}
                        {{ form|crispy }}
                        <div class="d-flex justify-content-between mt-4">
                            <a href="{% url 'inventory_check_detail' check_id=inventory_check.id %}" class="btn btn-outline-secondary">返回</a>
                            <button type="submit" class="btn btn-primary">{{ submit_text }}</button>
                        </div>
                    </form>
                </div>
                <div class="card-footer">
                    <div class="small text-muted">
                        <p>
                            <i class="bi bi-info-circle"></i>
                            请输入实际盘点的商品数量。如果与系统数量存在差异，系统会自动计算差异值。
                        </p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %} 